package com.phone580.app.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.BaseColumns;

public class AppHelperDatabase {

	private static final String DATABASE_NAME = "apphelper.db";
	private static final int DATABASE_VERSION = 3;
	
	public static final class DownloadInfoDB implements BaseColumns {
		
		public static final String TABLE_NAME = "download_info";
		
		public static final String URL = "url";
		
		public static final String FILE_NAME = "file_name";
		
		public static final String FILE_PATH = "file_path";
		
		public static final String FILE_SIZE = "file_size";
		
		public static final String COMPLETE_SIZE = "comlete_size";
		//finish unfinish error_pause
		public static final String STATUS = "status";
		
		public static final String ICON = "icon";
		
		public static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME
				+ "(" 
				+ _ID + "  INTEGER PRIMARY KEY,"
				+ URL + " NVARCHAR(1024),"
				+ FILE_NAME + " NVARCHAR(128),"
				+ FILE_PATH + " NVARCHAR(256),"
				+ FILE_SIZE + " INTEGER,"
				+ COMPLETE_SIZE + " INTEGER,"
				+ STATUS + " INTEGER,"
				+ ICON + " NVARCHAR(256)"
				+ ")";
	}
	
	
	public static class DatabaseHelper extends SQLiteOpenHelper {
		
		public DatabaseHelper(Context context) {
			super(context, AppHelperDatabase.DATABASE_NAME, null,
					AppHelperDatabase.DATABASE_VERSION);
		}

		@Override
		public void onCreate(SQLiteDatabase db) {
			db.execSQL(DownloadInfoDB.CREATE_TABLE);			
		}

		@Override
		public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
			db.execSQL("DROP TABLE IF EXISTS " + DownloadInfoDB.TABLE_NAME);
			onCreate(db);
		}
		
	}
}
